package com.chao.tlias.service.impl;

import com.chao.tlias.Pojo.JobOption;
import com.chao.tlias.mapper.EmpMapper;
import com.chao.tlias.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private EmpMapper empMapper;

    /**
     * 获取员工岗位数据
     */
    @Override
    public JobOption geEmpJobData() {
        //调用mapper接口，获取统计的数据
        List<Map<String, Object>> list= empMapper.countEmpJobData();

        //组装结果，并返回
        List<Object> jobList = list.stream().map(dataMap -> dataMap.get("pos")).toList();
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("num")).toList();

        return new JobOption(jobList, dataList);
    }

    /**
     * 统计员工性别信息
     */
    @Override
    public List<Map<String, Object>> GetEmpGenderData() {

        return empMapper.countEmpGenderData();
    }
}
